'''
set
不重复
'''

s1 = set()

"""
    set() -> new empty set object
    set(iterable) -> new set object

    Build an unordered collection of unique elements.
"""
s1.add(1)

s1 = {4, 3, 5, 6, 7, 9}
s2 = {1, 2, 3, 4}
# remove
# pop   discard(num)

# 不支持 + 号操作
# - 差集  difference()
print(s1 - s2)
print(s1.difference(s2))

# & 交集 intersection
print('#' * 30)

l1 = [5, 1, 2, 9, 0, 3]
l2 = [7, 2, 5, 7, 9]

s1 = set(l1)
s2 = set(l2)
# 对称差集
result = (s1 | s2) - (s1 & s2)
print(result)
result = s1 ^ s2  # 两个列表中不同的元素  symmetric_difference()
print(result)

# 可以打印但是是 不规律的
for i in enumerate(l1):
    print('in the set foreach print')
    print(i)
"""
in the set foreach print
(0, 5)
in the set foreach print
(1, 1)
in the set foreach print
(2, 2)
in the set foreach print
(3, 9)
in the set foreach print
(4, 0)
in the set foreach print
(5, 3)
"""

print(l1.sort())
print(l1)
